<script>
import { unique } from '@/utils/string'

export default {
  name: 'UiChartPie',
  inject: ['UiChart'],
  props: {
    data: {
      type: Array
    },
    label: {
      type: Object
    }
  },
  created() {
    this.id = unique()
    this.UiChart.addSeries({
      id: this.id,
      type: 'pie',
      data: this.data,
      label: this.label
    })
  },
  watch: {
    data() {
      this.UiChart && this.UiChart.updateSeries(this.id, {
        data: this.data
      })
    }
  },
  render() {
    return null
  },
  beforeDestroy() {
    this.UiChart.removeSeries(this.id)
  }
}
</script>
